package com.bootdo.xzl.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.MultiMatchQueryBuilder.Type;
import org.elasticsearch.index.query.Operator;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.RangeQueryBuilder;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.bootdo.common.dao.DictDao;
import com.bootdo.common.domain.DictDO;
import com.bootdo.common.elasticsearch.BaseElasticService;
import com.bootdo.common.utils.PageUtils;
import com.bootdo.common.utils.Query;
import com.bootdo.common.utils.R;
import com.bootdo.common.utils.ShiroUtils;
import com.bootdo.common.utils.StringUtils;
import com.bootdo.system.domain.UserDO;
import com.bootdo.xzl.dao.BuildingManagementDao;
import com.bootdo.xzl.dao.HousesInfoDao;
import com.bootdo.xzl.domain.BuildingManagementDO;
import com.bootdo.xzl.domain.HousesImgInfoDO;
import com.bootdo.xzl.domain.HousesInfoDO;
import com.bootdo.xzl.service.HousesInfoService;

/**
 * 房源信息表
 * 
 * @author chenhuan
 * @email huan.chen@i-soft.com.cn
 * @date 2019-11-19 10:53:06
 */

@RestController
@RequestMapping("/xzl/housesInfo")
public class HousesInfoController {

	@Autowired
	private BaseElasticService baseElasticService;

	@Autowired
	private HousesInfoService housesInfoService;

	@Autowired
	private DictDao dictDao;

	@Autowired
	private HousesInfoDao housesInfoDao;

	@Autowired
	private BuildingManagementDao buildingManagementDao;

	@GetMapping()
	@RequiresPermissions("xzl:housesInfo:housesInfo")
	String HousesInfo(Model model) {
		
		// 用户信息
		UserDO user = ShiroUtils.getUser();
		model.addAttribute("user", user);
		
		return "xzl/housesInfo/housesInfo";
	}

	@ResponseBody
	@GetMapping("/list")
	// @RequiresPermissions("xzl:housesInfo:housesInfo")
	public PageUtils list(@RequestParam Map<String, Object> params,Model model) {
		// 用户信息
		UserDO user = ShiroUtils.getUser();
		model.addAttribute("user", user);
		if (params.containsKey("es") && params.get("es") != null) {

			// 拼接检索条件
			BoolQueryBuilder queryBuilder = buildEsParam(params);

			SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();

			if (params.containsKey("esText") && params.get("esText") != null) {
				if (params.get("esText").toString().equals("")) {
					QueryBuilder matchAll = QueryBuilders.matchAllQuery();
			        queryBuilder.filter(matchAll);
				} else {
			
					Map<String, Float> fields = new HashMap<String, Float>(8);
				      //fields.put("moneyMonth", 4.0f);
				      //fields.put("money", 3.0f);
				      fields.put("title", 2.0f);
				      fields.put("officeName", 1.0f);

						QueryBuilder entireReg = QueryBuilders.multiMatchQuery(params.get("esText").toString(), "officeName","title")
					          .fields(fields)
					          .type(Type.CROSS_FIELDS)  //合并字段查询
					          .operator(Operator.AND);
				        queryBuilder.filter(entireReg);
				}
			}

			int offset = Integer.valueOf(params.get("offset").toString());
			int limit = Integer.valueOf(params.get("limit").toString());

			searchSourceBuilder.from(offset);
			searchSourceBuilder.sort("id", SortOrder.DESC);
			searchSourceBuilder.size(limit);
			searchSourceBuilder.query(queryBuilder);

            int countTatal=0;
            //判断所以是否为空
			PageUtils pageUtils = new PageUtils(null, 0);
			List<HousesInfoDO> lstHoseInfo =null;
			Map<String, Object> resMap = baseElasticService.searchListAndTatal("housesinfo", searchSourceBuilder, HousesInfoDO.class);
			   if(resMap!=null && resMap.size()>0) {
       		    lstHoseInfo = (List<HousesInfoDO>) resMap.get("resList");
       	   }
  
      	   pageUtils.setTotal(Integer.valueOf(resMap.get("totalHits").toString()));
    	   pageUtils.setRows(lstHoseInfo);
			return pageUtils;
		}else {
			// 查询列表数据
			Query query = new Query(params);
			List<HousesInfoDO> housesInfoList = housesInfoService.list(query);
			int total = housesInfoService.count(query);
			PageUtils pageUtils = new PageUtils(housesInfoList, total);
			return pageUtils;
		}

	
	}

	
	/**
            *拼装查询条件
     * @param query
     * @return
     */
    public static BoolQueryBuilder buildEsParam(Map<String, Object> params) {
 
        BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
        
        //filter 效率比 must高的多 
        //删除区分
        queryBuilder.filter(QueryBuilders.matchQuery("del_flag", "0"));
	    //删除区分
        queryBuilder.mustNot(QueryBuilders.regexpQuery("img_flg", "[0-9]+"));
        //queryBuilder.filter(QueryBuilders.matchQuery("img_flg", ""));
        //类别
        queryBuilder.filter(QueryBuilders.matchQuery("type", "housesInfo"));
    	// 房源性质
		if (params.containsKey("officeProperty") && params.get("officeProperty") != null
				&& StringUtils.isNotEmpty(params.get("officeProperty").toString())) {
			  queryBuilder.filter(QueryBuilders.matchQuery("office_property",
						params.get("officeProperty")));
		}
		// 用途
		if (params.containsKey("purpose") && params.get("purpose") != null
				&& StringUtils.isNotEmpty(params.get("purpose").toString())) {
			  queryBuilder.filter(QueryBuilders.matchQuery("purpose", params.get("purpose")));
		}
		
		// 房源类别
		if (params.containsKey("officeType") && params.get("officeType") != null
				&& StringUtils.isNotEmpty(params.get("officeType").toString())) {
			 queryBuilder.filter(QueryBuilders.matchQuery("office_type", params.get("officeType")));
		}

		// 区域
		if (params.containsKey("area") && params.get("area") != null) {
			 queryBuilder.filter(QueryBuilders.matchQuery("area", params.get("area")));
			
		}

		// 地铁
		if (params.containsKey("metro") && params.get("metro") != null) {
			queryBuilder.filter(QueryBuilders.matchQuery("metro", params.get("metro")));
		}

		// 面积区间
		if (params.containsKey("startArea") && params.get("endArea") != null) {
			 queryBuilder.filter(QueryBuilders.rangeQuery("built_area").from(params.get("startArea")).to(params.get("endArea")));

		}

		// 面积区间
		if (params.containsKey("startArea") && params.get("endArea") == null) {
			queryBuilder.filter(QueryBuilders.rangeQuery("built_area").gte(params.get("startArea")));
		}

		// 装修
		if (params.containsKey("renovation") && params.get("renovation") != null) {
			queryBuilder.filter(QueryBuilders.matchQuery("renovation", params.get("renovation")));

		}

		// 经典写字楼
		if (params.containsKey("id") && params.get("id") != null) {
			queryBuilder.filter( QueryBuilders.matchQuery("office_building_management_id",
					params.get("id")));

		}

		// 形态
		if (params.containsKey("hform") && params.get("hform") != null) {

			queryBuilder.filter( QueryBuilders.matchQuery("hform", params.get("hform")));

		}

		// 行业
		if (params.containsKey("industry") && params.get("industry") != null) {

			queryBuilder.filter( QueryBuilders.matchQuery("industry", params.get("industry")));

		}

		// 附属设施
		if (params.containsKey("facilities") && params.get("facilities") != null) {
			queryBuilder.filter( QueryBuilders.matchQuery("facilities", params.get("facilities")));

		}

		//临街情况
		if (params.containsKey("streetCondition") && params.get("streetCondition") != null) {
			queryBuilder.filter( QueryBuilders.matchQuery("street_condition", params.get("streetCondition")));

		}
		
		//楼层情况
		if (params.containsKey("floorCondition") && params.get("floorCondition") != null) {
			queryBuilder.filter( QueryBuilders.matchQuery("floor_condition", params.get("floorCondition")));

		}
		//追加经纪人
		if (params.containsKey("telname") && params.get("telname") != null) {
			queryBuilder.filter(QueryBuilders.matchQuery("telname", params.get("telname")));

		}
		//经营状况
		if (params.containsKey("managementCondition") && params.get("managementCondition") != null) {
			queryBuilder.filter(QueryBuilders.matchQuery("management_condition", params.get("managementCondition")));

		}

/*		// 租金区间(日)
		if (params.containsKey("rentMethod") && "1".equals(params.get("rentMethod").toString())) {

			if (params.containsKey("startMoney") && !params.containsKey("endMoney")) {
				queryBuilder.filter(QueryBuilders.rangeQuery("money").gte(params.get("startMoney")));
			}

			if (params.containsKey("startMoney") && params.containsKey("endMoney")) {
//				queryBuilder.filter( QueryBuilders.rangeQuery("money").from(params.get("startMoney"))
//						.to(params.get("endMoney")));
		      queryBuilder.filter(QueryBuilders.rangeQuery("money").gte(params.get("startMoney")));
		      queryBuilder.filter(QueryBuilders.rangeQuery("money").gte(params.get("startMoney")));
			}

		}

		// 租金区间(月)
		if (params.containsKey("rentMethod") && "2".equals(params.get("rentMethod").toString())) {

			if (params.containsKey("startMoneyMonth") && !params.containsKey("endMoneyMonth")) {
				queryBuilder.filter(QueryBuilders.rangeQuery("money_month")
						.gte(params.get("startMoneyMonth")));
			}

			if (params.containsKey("startMoneyMonth") && params.containsKey("endMoneyMonth")) {
				queryBuilder.filter(QueryBuilders.rangeQuery("money_month")
						.from(params.get("startMoneyMonth")).to(params.get("endMoneyMonth")));
			}

		}*/
		
		// 租金区间
		if (params.containsKey("rentMethod") && "1".equals(params.get("rentMethod").toString())) {

			if (params.containsKey("startMoney") && !params.containsKey("endMoney")) {
				QueryBuilder money = QueryBuilders.rangeQuery("money").gte(params.get("startMoney"));
				queryBuilder.must(money);
			}

			if (params.containsKey("startMoney") && params.containsKey("endMoney")) {
				RangeQueryBuilder money = QueryBuilders.rangeQuery("money").from(params.get("startMoney"))
						.to(params.get("endMoney"));
				queryBuilder.must(money);
			}

		}

		if (params.containsKey("rentMethod") && "2".equals(params.get("rentMethod").toString())) {

			if (params.containsKey("startMoneyMonth") && !params.containsKey("endMoneyMonth")) {
				QueryBuilder moneyMonth = QueryBuilders.rangeQuery("money_month")
						.gte(params.get("startMoneyMonth"));
				queryBuilder.must(moneyMonth);
			}

			if (params.containsKey("startMoneyMonth") && params.containsKey("endMoneyMonth")) {
				RangeQueryBuilder moneyMonth = QueryBuilders.rangeQuery("money_month")
						.from(params.get("startMoneyMonth")).to(params.get("endMoneyMonth"));
				queryBuilder.must(moneyMonth);
			}

		}
        return queryBuilder;
    }
	
	@GetMapping("/add")
	@RequiresPermissions("xzl:housesInfo:add")
	String add(Model model) {

		// 用户信息
		UserDO user = ShiroUtils.getUser();
		model.addAttribute("user", user);

		// 区域
		Map<String, Object> areaParam = new HashMap<>();
		areaParam.put("type", "area");
		List<DictDO> areaList = dictDao.list(areaParam);
		model.addAttribute("areaList", areaList);

		// 商圈
		Map<String, Object> businessParam = new HashMap<>();
		businessParam.put("type", "business");
		List<DictDO> businessList = dictDao.list(businessParam);
		model.addAttribute("businessList", businessList);

		// 地铁线路
		Map<String, Object> metroParam = new HashMap<>();
		metroParam.put("type", "metro");
		List<DictDO> metroList = dictDao.list(metroParam);
		model.addAttribute("metro", metroList);

		// 装修
		Map<String, Object> renovationParam = new HashMap<>();
		renovationParam.put("type", "renovation");
		List<DictDO> renovationList = dictDao.list(renovationParam);
		model.addAttribute("renovationList", renovationList);

		// 租金方式
		Map<String, Object> rentMethodParam = new HashMap<>();
		rentMethodParam.put("type", "rentMethod");
		List<DictDO> rentMethodList = dictDao.list(rentMethodParam);
		model.addAttribute("rentMethodList", rentMethodList);

		// 类别
		Map<String, Object> officeTypeParam = new HashMap<>();
		officeTypeParam.put("type", "officeType");
		List<DictDO> officeTypeList = dictDao.list(officeTypeParam);
		model.addAttribute("officeTypeList", officeTypeList);

		// 性质
		Map<String, Object> officeSituationParam = new HashMap<>();
		officeSituationParam.put("type", "officeSituation");
		List<DictDO> officeSituationList = dictDao.list(officeSituationParam);
		model.addAttribute("officeSituationList", officeSituationList);

		// 用途
		Map<String, Object> purposeParam = new HashMap<>();
		purposeParam.put("type", "purpose");
		List<DictDO> purposeList = dictDao.list(purposeParam);
		model.addAttribute("purposeList", purposeList);

		// 用途
		Map<String, Object> deposiParam = new HashMap<>();
		deposiParam.put("type", "deposit");
		List<DictDO> depositList = dictDao.list(deposiParam);
		model.addAttribute("depositList", depositList);

		// 经典写字楼
		Map<String, Object> buildingManagementParam = new HashMap<>();
		List<BuildingManagementDO> buildingManagementList = buildingManagementDao.list(buildingManagementParam);
		
		BuildingManagementDO entity = new  BuildingManagementDO();
		entity.setOfficeName("不限");
		entity.setId(-1);
		buildingManagementList.add(0, entity);
		
		model.addAttribute("buildingManagementList", buildingManagementList);

		// 形态
		Map<String, Object> hformParam = new HashMap<>();
		hformParam.put("type", "hform");
		List<DictDO> hformList = dictDao.list(hformParam);
		model.addAttribute("hformList", hformList);

		// 行业
		Map<String, Object> industryParam = new HashMap<>();
		industryParam.put("type", "industry");
		List<DictDO> industryList = dictDao.list(industryParam);
		model.addAttribute("industryList", industryList);

		// 附属设施
		//Map<String, Object> facilitiesParam = new HashMap<>();
		//facilitiesParam.put("type", "facilities");
		//List<DictDO> facilitiesList = dictDao.list(facilitiesParam);
		//model.addAttribute("facilitiesList", facilitiesList);

		// 临街情况
		Map<String, Object> streetConditionParam = new HashMap<>();
		streetConditionParam.put("type", "street_condition");
		List<DictDO> streetConditionList = dictDao.list(streetConditionParam);
		model.addAttribute("streetConditionList", streetConditionList);

		// 楼层情况
		Map<String, Object> floorConditionParam = new HashMap<>();
		floorConditionParam.put("type", "floor_condition");
		List<DictDO> floorConditionList = dictDao.list(floorConditionParam);
		model.addAttribute("floorConditionList", floorConditionList);

		// 经营状况
		Map<String, Object> managementConditionParam = new HashMap<>();
		managementConditionParam.put("type", "management_condition");
		List<DictDO> managementConditionParamList = dictDao.list(managementConditionParam);
		model.addAttribute("managementConditionParamList", managementConditionParamList);

		return "xzl/housesInfo/add";
	}

	@GetMapping("/edit/{id}")
	@RequiresPermissions("xzl:housesInfo:edit")
	String edit(@PathVariable("id") Integer id, Model model) {

		HousesInfoDO housesInfo = housesInfoService.get(id);

		// 金额判断
		if (null != housesInfo && StringUtils.isNotEmpty(housesInfo.getRentMethod())) {

			if ("2".equals(housesInfo.getRentMethod())) {

				housesInfo.setMoney(housesInfo.getMoneyMonth());
			}
		}

		model.addAttribute("housesInfo", housesInfo);

		// 用户信息
		UserDO user = ShiroUtils.getUser();
		model.addAttribute("user", user);

		// 区域
		Map<String, Object> areaParam = new HashMap<>();
		areaParam.put("type", "area");
		areaParam.put("value", housesInfo.getArea());
		List<DictDO> areaList = housesInfoDao.dictListByValue(areaParam);
		model.addAttribute("areaList", areaList);

		// 商圈
		Map<String, Object> businessParam = new HashMap<>();
		businessParam.put("type", "business");
		businessParam.put("value", housesInfo.getBusiness());
		List<DictDO> businessList = housesInfoDao.dictListByValue(businessParam);
		model.addAttribute("businessList", businessList);

		// 地铁线路
		Map<String, Object> metroParam = new HashMap<>();
		metroParam.put("type", "metro");
		metroParam.put("value", housesInfo.getMetro());
		List<DictDO> metroList = housesInfoDao.dictListByValue(metroParam);
		model.addAttribute("metro", metroList);

		// 装修
		Map<String, Object> renovationParam = new HashMap<>();
		renovationParam.put("type", "renovation");
		renovationParam.put("value", housesInfo.getRenovation());
		List<DictDO> renovationList = housesInfoDao.dictListByValue(renovationParam);
		model.addAttribute("renovationList", renovationList);

		// 租金方式
		Map<String, Object> rentMethodParam = new HashMap<>();
		rentMethodParam.put("type", "rentMethod");
		rentMethodParam.put("value", housesInfo.getRentMethod());
		List<DictDO> rentMethodList = housesInfoDao.dictListByValue(rentMethodParam);
		model.addAttribute("rentMethodList", rentMethodList);

		// 类别
		Map<String, Object> officeTypeParam = new HashMap<>();
		officeTypeParam.put("type", "officeType");
		officeTypeParam.put("value", housesInfo.getOfficeType());
		List<DictDO> officeTypeList = housesInfoDao.dictListByValue(officeTypeParam);
		model.addAttribute("officeTypeList", officeTypeList);

		// 性质
		Map<String, Object> officeSituationParam = new HashMap<>();
		officeSituationParam.put("type", "officeSituation");
		officeSituationParam.put("value", housesInfo.getOfficeSituation());
		List<DictDO> officeSituationList = housesInfoDao.dictListByValue(officeSituationParam);
		model.addAttribute("officeSituationList", officeSituationList);

		// 用途
		Map<String, Object> purposeParam = new HashMap<>();
		purposeParam.put("type", "purpose");
		purposeParam.put("value", housesInfo.getPurpose());
		List<DictDO> purposeList = housesInfoDao.dictListByValue(purposeParam);
		model.addAttribute("purposeList", purposeList);

		// 用途
		Map<String, Object> deposiParam = new HashMap<>();
		deposiParam.put("type", "deposit");
		deposiParam.put("value", housesInfo.getDeposit());
		List<DictDO> depositList = housesInfoDao.dictListByValue(deposiParam);
		model.addAttribute("depositList", depositList);

		// 经典写字楼
		List<BuildingManagementDO> buildingManagementList = null;
		if(housesInfo.getOfficeBuildingManagementId()!=null){
			
			buildingManagementList = housesInfoDao.managementById(housesInfo.getOfficeBuildingManagementId());
			
			if(housesInfo.getOfficeBuildingManagementId()!=null  && housesInfo.getOfficeBuildingManagementId()==-1){
				BuildingManagementDO entity = new  BuildingManagementDO();
				entity.setOfficeName("不限");
				entity.setId(-1);
				buildingManagementList.add(0, entity);
			}else{
				BuildingManagementDO entity = new  BuildingManagementDO();
				entity.setOfficeName("不限");
				entity.setId(-1);
				buildingManagementList.add(1, entity);
			}
			model.addAttribute("buildingManagementList", buildingManagementList);
		}else{
			buildingManagementList = buildingManagementDao.list(new HashMap<>(0))==null? new ArrayList<BuildingManagementDO>():buildingManagementDao.list(new HashMap<>(0));
			BuildingManagementDO entity = new  BuildingManagementDO();
			entity.setOfficeName("不限");
			entity.setId(-1);
			buildingManagementList.add(0, entity);
			model.addAttribute("buildingManagementList", buildingManagementList);
		}
		
		// 形态
		Map<String, Object> hformParam = new HashMap<>();
		hformParam.put("type", "hform");
		hformParam.put("value", housesInfo.getHform());
		List<DictDO> hformList = housesInfoDao.dictListByValue(hformParam);
		model.addAttribute("hformList", hformList);

		// 行业
		Map<String, Object> industryParam = new HashMap<>();
		industryParam.put("type", "industry");
		industryParam.put("value", housesInfo.getIndustry());
		List<DictDO> industryList = housesInfoDao.dictListByValue(industryParam);
		model.addAttribute("industryList", industryList);

		// 附属设施
		//Map<String, Object> facilitiesParam = new HashMap<>();
		//facilitiesParam.put("type", "facilities");
		//facilitiesParam.put("value", housesInfo.getFacilities());
		//List<DictDO> facilitiesList = housesInfoDao.dictListByValue(facilitiesParam);
		//model.addAttribute("facilitiesList", facilitiesList);

		// 临街情况
		Map<String, Object> streetConditionParam = new HashMap<>();
		streetConditionParam.put("type", "street_condition");
		streetConditionParam.put("value", housesInfo.getStreetCondition());
		List<DictDO> streetConditionList = housesInfoDao.dictListByValue(streetConditionParam);
		model.addAttribute("streetConditionList", streetConditionList);

		// 楼层情况
		Map<String, Object> floorConditionParam = new HashMap<>();
		floorConditionParam.put("type", "floor_condition");
		floorConditionParam.put("value", housesInfo.getFloorCondition());
		List<DictDO> floorConditionList = housesInfoDao.dictListByValue(floorConditionParam);
		model.addAttribute("floorConditionList", floorConditionList);

		// 经营状况
		Map<String, Object> managementConditionParam = new HashMap<>();
		managementConditionParam.put("type", "management_condition");
		managementConditionParam.put("value", housesInfo.getManagementCondition());
		List<DictDO> managementConditionParamList = housesInfoDao.dictListByValue(managementConditionParam);
		model.addAttribute("managementConditionParamList", managementConditionParamList);

		return "xzl/housesInfo/edit";
	}

	/**
	 * 保存
	 */
	@ResponseBody
	@PostMapping("/save")
	@RequiresPermissions("xzl:housesInfo:add")
	public R save(HousesInfoDO housesInfo) {
		if (housesInfoService.save(housesInfo) > 0) {
			return R.ok();
		}
		return R.error();
	}

	/**
	 * 修改
	 */
	@ResponseBody
	@RequestMapping("/update")
	@RequiresPermissions("xzl:housesInfo:edit")
	public R update(HousesInfoDO housesInfo) {
		housesInfoService.update(housesInfo);
		return R.ok();
	}

	/**
	 * 删除
	 */
	@PostMapping("/remove")
	@ResponseBody
	@RequiresPermissions("xzl:housesInfo:remove")
	public R remove(Integer id) {
		if (housesInfoService.remove(id) > 0) {
			return R.ok();
		}
		return R.error();
	}

	/**
	 * 删除
	 */
	@PostMapping("/batchRemove")
	@ResponseBody
	@RequiresPermissions("xzl:housesInfo:batchRemove")
	public R remove(@RequestParam("ids[]") Integer[] ids) {
		housesInfoService.batchRemove(ids);
		return R.ok();
	}

	@ResponseBody
	@GetMapping("/dict")
	// @RequiresPermissions("xzl:housesInfo:housesInfo")
	public List<DictDO> dict(@RequestParam Map<String, Object> params) {

		// 查询列表数据
		return housesInfoService.dict(params);
	}

	@ResponseBody
	@GetMapping("/imagesByofficeId")
	@RequiresPermissions("xzl:housesInfo:housesInfo")
	public List<HousesImgInfoDO> imagesByofficeId(@RequestParam Map<String, Object> params) {

		// 查询列表数据
		return housesInfoService.imagesByofficeId(params);
	}

	// 详情接口
	@ResponseBody
	@GetMapping("/housesInfo")
	// @RequiresPermissions("xzl:housesInfo:housesInfo")
	public HousesInfoDO housesInfo(@RequestParam("id") Integer id) {

		return housesInfoService.housesInfo(id);
	}

	@GetMapping("/preview")
	@RequiresPermissions("xzl:housesInfo:housesInfo")
	String preview(@RequestParam("id") Integer id,@RequestParam("officeProperty") Integer officeProperty,@RequestParam("purpose") Integer purpose, Model model) {

		model.addAttribute("id", id);
		model.addAttribute("officeProperty", officeProperty);
		model.addAttribute("purpose", purpose);
		return "xzl/housesInfo/fykz";
	}

}
